<?php
header('Content-Type:text/html;charset=utf-8');

?>
<html>
  <head>
    <title>点餐系统</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <script src="js/jquery-1.11.3.js"></script>
    <script src="js/bootstrap.js"></script>
  </head>
  <body>
    <?php include 'nav.php' ?>
    <div class="container">
    <div class="col-xs-2">
      <div class="list-group" style="margin-top:20px" align="center">
        <a class="btn btn-primary list-group-item" role="button" data-toggle="collapse" href="#aaa" aria-expanded="false" aria-controls="collapseExample"> 菜品列表 </a>
        <a class="btn btn-primary list-group-item" role="button" data-toggle="collapse" href="#bbb" aria-expanded="false" aria-controls="collapseExample"> 添加菜品 </a>
      </div>
    </div>
    <div class="col-xs-10">
    <div class="collapse" id="aaa">
      <div class="panel panel-primary" style="margin-top:20px">
        <div class="panel-heading">
          <div class="row">
            <div class="col-xs-8">
              <span class="glyphicon glyphicon-th-list"></span>
              可选菜品 </div>
            <form class="form-horizontal" method="post" action="cpgl.php">
              <div class="col-xs-4">
                <div class="input-group">
                  <input type="text" placeholder="菜名" class="form-control" name="caiming">
                  <div class="input-group-btn">
                    <select class="btn btn-default" style="height:34px" name="cailx">
                      <option >全部</option>
                      <option >烧菜</option>
                      <option >炒菜</option>
                    </select>
                    <button type="submit" class="btn btn-default" >
                    <span class="glyphicon glyphicon-search" style="height:20px">
                    </span>
                    </button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
        <div class="panel-body">
          <div class="row">
            <?php 
              @$caiming=$_POST['caiming'];
              @$cailx=$_POST['cailx'];
              
              $PDO=new PDO('mysql:dbname=diancan;charset=UTF8;','root');
		      		$cc=$PDO->prepare('select * from VTbiao where name=:aa');
  						$cc->execute(array('aa'=>$caiming));
  						$BA=$cc->fetchAll();
              
              
			      	foreach ($BA as $BB => $BC) { ?>
            <div class="col-xs-2">
              <div class="thumbnail">
                <img style="width:100px;height:100px" src="<?php echo $BC['picture']; ?>"/>
                <div class="caption text-center"><?php echo $BC['name'].$BC['unitPrice']; ?>
                  <a href="#"></a>
                </div>
              </div>
            </div>
            <?php }
            
              if($cailx!='炒菜'&&$cailx!='烧菜'){
                $cl=$PDO->prepare('select * from VTbiao');
                $cl->execute(array('bb'=>$cailx));
                $CL=$cl->fetchAll();               
                  foreach ($CL as $CLA => $CLB) { ?>
            <div class="col-xs-2">
              <div class="thumbnail">
                <img style="width:100px;height:100px" src="<?php echo $CLB['picture']; ?>"/>
                <div class="caption text-center"><?php echo $CLB['name'].$CLB['unitPrice']; ?>
                  <a href="#"></a>
                </div>
              </div>
            </div>
            <?php }
              }else{
                $cl=$PDO->prepare('select * from VTbiao where type=:bb');
                $cl->execute(array('bb'=>$cailx));
                $CL=$cl->fetchAll();              
                  foreach ($CL as $CLA => $CLB) { ?>
            <div class="col-xs-2">
              <div class="thumbnail">
                <img style="width:100px;height:100px" src="<?php echo $CLB['picture']; ?>"/>
                <div class="caption text-center"><?php echo $CLB['name'].$CLB['unitPrice']; ?>
                  <a href="#"></a>
                </div>
              </div>
            </div>
            <?php }
              } ?>
          </div>
        </div>
      </div>
    </div>
    <div class="collapse col-xs-5" id="bbb">
    <div class="panel panel-primary">
    <div class="panel-heading">添加菜品</div>
    <div class="panel-body">
    <?php

					@$file=$_FILES['file1'];


					if(!empty($file)&&$file['error']==0){
						$fileName='';
						$fileInfo=pathinfo($file['name']);
						
						$str='abcdefghijklmnopqrestuvwxyz';
						$name='';
						for ($i=0; $i<10 ; $i++) { 
							$name=$name.$str[rand(0,strlen($str)-1)];
						}

						$fileName=$name.'.'.$fileInfo['extension'];

						move_uploaded_file($file['tmp_name'],$fileName);
					}
			   ?>
    <form class="form-horizontal" method="post" action="#" enctype="multipart/form-data">
    <input type="file" data-input="false" name="file1" class="filestyle"  style="height:40px">
    <div class="form-group" style="height:40px">
      <label for="caiName" class="control-label col-xs-4">菜品名字</label>
      <div class="col-xs-8">
        <input id ="caiName" type="text" class="form-control" name="cpmz"  required="required">
      </div>
    </div>
    <div class="form-group">
      <label for="jg" class="control-label col-xs-4">价格</label>
      <div class="col-xs-8">
        <input id="jg" type="text" class="form-control" name="jg" required>
      </div>
    </div>
    <div class="from-group">
      <label class="control-label col-xs-4">菜品类型</label>
      <div class="col-xs-8" style="padding:0%0%0%10px">
        <select class="btn btn-default" style="height:34px;width:100%">
          <option>炒菜</option>
          <option>烧菜</option>
        </select>
      </div>
    </div>
    </div>
    <div class="modal-footer">
      <button type="submit" class="btn btn-primary" >登录</button>
      <a href="zc.php" class="btn btn-default">注册</a>
    </div>
    </div>
    </div>
    </div>
  </body>
</html>